/* Tables0.do (STATA)
	Tables and figures for asset prices without special demand.
	by Ralph Koijen & Motohiro Yogo */

#delimit ;
clear all;
set more off;
set type double;
set scheme s1mono;

cap log close;
log using Tables0, replace;

/* Define local and global variables */

local path = "../../figures";


/* Load data */

u year counter_euro type Ctype market yield* DLfx* DLmb* Dyield* DEret*
	if ((counter_euro!="USA" & type==1) | (counter_euro=="USA" & type!=1)) & type==Ctype
	using Valuation0, clear;

/* Aggregate across exchange rates */

collapse (mean) yield* DLfx* DLmb* Dyield* DEret* [aw=market], by(year type) fast;

/* Report in percent */

foreach var of varlist yield* DLfx* DLmb* Dyield* DEret* {;
	replace `var' = 100*`var';
};

/* Table: Mean convenience yield */

tabstat DLfx* if type==1, s(mean semean) format(%9.2f);

tabstat Dyield* if type==2, s(mean semean) format(%9.2f);

tabstat DLmb* if type==3, s(mean semean) format(%9.2f);

tabstat DEret*, by(type) s(mean semean) format(%9.2f) not;

/* Label variables */

label var yield		"Long-term yield";
label var yield6	"Convenience yield";

/* Figure: Convenience yield on long-term debt */

twoway bar yield6 yield year if type==2, color(gs8 gs4)
	ylabel(0(1)6, angle(0))
	tlabel(2004(4)2020)
	ytitle("Yield (%)")
	legend(pos(1) ring(0) col(1));

/* Output figure */

graph export "`path'/convenience.eps", replace;

sort year;
l year yield yield6 Dyield if type==2;

log close;
